package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

public class ChartPointCollection {
   ArrayList a;
   private Series b;

   ChartPointCollection(Series parent) {
      this.b = parent;
      this.a = new ArrayList();
   }

   public Iterator iterator() {
      return this.a.iterator();
   }

   public void clear() {
      this.a.clear();
   }

   public void removeAt(int index) {
      for(int var2 = 0; var2 < this.a.size(); ++var2) {
         ChartPoint var3 = (ChartPoint)this.a.get(var2);
         if (var3.a == index) {
            this.a.remove(index);
            return;
         }
      }

   }

   public int getCount() {
      int var1 = 0;
      if (this.b.l() != null) {
         boolean var2 = false;
         boolean[] var3 = new boolean[]{var2};
         ArrayList var4 = this.b.l().a(true, this.b.h().d().f(), var3);
         var2 = var3[0];
         var1 += var4.size();
         if (this.b.h().d().getPlotVisibleCells()) {
            for(int var5 = 0; var5 < var4.size(); ++var5) {
               zit var6 = (zit)var4.get(var5);
               if (!var6.d) {
                  --var1;
               }
            }
         }

         if (this.b.s() != null && (this.b.getType() == 46 || this.b.getType() == 49)) {
            ++var1;
         }
      }

      return var1;
   }

   public ChartPoint get(int index) {
      boolean var2 = false;
      boolean[] var3 = new boolean[]{var2};
      ChartPoint var4 = this.a(index, var3);
      var2 = var3[0];
      if (var2 && this.b.D() != null) {
         var4.getShapeProperties().a(this.b.getShapeProperties(), (CopyOptions)null);
      }

      return var4;
   }

   void a(ChartPoint var1) {
      for(int var2 = 0; var2 < this.a.size(); ++var2) {
         ChartPoint var3 = (ChartPoint)this.a.get(var2);
         if (var3.a > var1.a) {
            this.a.add(var2, var1);
            return;
         }

         if (var3.a == var1.a) {
            this.a.set(var2, var1);
            return;
         }
      }

      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
   }

   ChartPoint a(int var1) {
      boolean var2 = false;
      boolean[] var3 = new boolean[]{var2};
      ChartPoint var4 = this.a(var1, var3);
      var2 = var3[0];
      return var4;
   }

   private ChartPoint a(int var1, boolean[] var2) {
      var2[0] = true;
      ChartPoint var3;
      if (this.a.size() == 0) {
         var3 = new ChartPoint(this.b, var1);
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var3);
         return var3;
      } else {
         if (this.a.size() > var1) {
            var3 = (ChartPoint)this.a.get(var1);
            if (var1 == var3.a) {
               var2[0] = false;
               return var3;
            }
         }

         return this.a(var1, 0, this.a.size() - 1, var2);
      }
   }

   private ChartPoint a(int var1, int var2, int var3, boolean[] var4) {
      var4[0] = true;
      ChartPoint var6;
      ChartPoint var8;
      switch(var3 - var2) {
      case 0:
         ChartPoint var5 = (ChartPoint)this.a.get(var2);
         if (var1 > var5.a) {
            var6 = new ChartPoint(this.b, var1);
            if (var3 == this.a.size() - 1) {
               com.aspose.cells.b.a.a.ze.a(this.a, (Object)var6);
            } else {
               this.a.add(var3 + 1, var6);
            }

            return var6;
         } else {
            if (var1 == var5.a) {
               var4[0] = false;
               return var5;
            }

            var6 = new ChartPoint(this.b, var1);
            this.a.add(var2, var6);
            return var6;
         }
      case 1:
         var6 = (ChartPoint)this.a.get(var2);
         ChartPoint var7 = (ChartPoint)this.a.get(var3);
         if (var1 > var7.a) {
            var8 = new ChartPoint(this.b, var1);
            if (var3 == this.a.size() - 1) {
               com.aspose.cells.b.a.a.ze.a(this.a, (Object)var8);
            } else {
               this.a.add(var3 + 1, var8);
            }

            return var8;
         } else if (var1 == var7.a) {
            var4[0] = false;
            return var7;
         } else if (var1 > var6.a && var1 < var7.a) {
            var8 = new ChartPoint(this.b, var1);
            this.a.add(var3, var8);
            return var8;
         } else {
            if (var1 == var6.a) {
               var4[0] = false;
               return var6;
            }

            var8 = new ChartPoint(this.b, var1);
            this.a.add(var2, var8);
            return var8;
         }
      default:
         var8 = (ChartPoint)this.a.get(var2);
         ChartPoint var9 = (ChartPoint)this.a.get(var3);
         ChartPoint var10;
         if (var1 > var9.a) {
            var10 = new ChartPoint(this.b, var1);
            if (var3 == this.a.size() - 1) {
               com.aspose.cells.b.a.a.ze.a(this.a, (Object)var10);
            } else {
               this.a.add(var3 + 1, var10);
            }

            return var10;
         } else if (var1 == var9.a) {
            var4[0] = false;
            return var9;
         } else if (var1 > var8.a && var1 < var9.a) {
            int var13 = (var3 + var2) / 2;
            ChartPoint var11 = (ChartPoint)this.a.get(var13);
            ChartPoint var12;
            if (var1 > var11.a) {
               if (var3 - var13 == 1) {
                  var12 = new ChartPoint(this.b, var1);
                  this.a.add(var3, var12);
                  return var12;
               } else {
                  return this.a(var1, var13 + 1, var3 - 1, var4);
               }
            } else if (var1 == var11.a) {
               var4[0] = false;
               return var11;
            } else if (var13 - var2 == 1) {
               var12 = new ChartPoint(this.b, var1);
               this.a.add(var13, var12);
               return var12;
            } else {
               return this.a(var1, var2 + 1, var13 - 1, var4);
            }
         } else if (var1 == var8.a) {
            var4[0] = false;
            return var8;
         } else {
            var10 = new ChartPoint(this.b, var1);
            this.a.add(var2, var10);
            return var10;
         }
      }
   }

   int a() {
      return this.a.size();
   }

   ChartPoint b(int var1) {
      if (this.a.size() == 0) {
         return null;
      } else {
         if (this.a.size() > var1) {
            ChartPoint var2 = (ChartPoint)this.a.get(var1);
            if (var2.a == var1) {
               return var2;
            }
         }

         return this.a(var1, 0, this.a.size() - 1);
      }
   }

   private ChartPoint a(int var1, int var2, int var3) {
      switch(var3 - var2) {
      case 0:
         ChartPoint var4 = (ChartPoint)this.a.get(var2);
         if (var1 == var4.a) {
            return var4;
         }

         return null;
      case 1:
         ChartPoint var5 = (ChartPoint)this.a.get(var2);
         ChartPoint var6 = (ChartPoint)this.a.get(var3);
         if (var1 == var5.a) {
            return var5;
         } else {
            if (var1 == var6.a) {
               return var6;
            }

            return null;
         }
      default:
         ChartPoint var7 = (ChartPoint)this.a.get(var2);
         ChartPoint var8 = (ChartPoint)this.a.get(var3);
         if (var1 > var8.a) {
            return null;
         } else if (var1 == var8.a) {
            return var8;
         } else if (var1 > var7.a && var1 < var8.a) {
            int var9 = (var3 + var2) / 2;
            ChartPoint var10 = (ChartPoint)this.a.get(var9);
            if (var1 > var10.a) {
               return var3 - var9 == 1 ? null : this.a(var1, var9 + 1, var3 - 1);
            } else if (var1 == var10.a) {
               return var10;
            } else {
               return var9 - var2 == 1 ? null : this.a(var1, var2 + 1, var9 - 1);
            }
         } else {
            return var1 == var7.a ? var7 : null;
         }
      }
   }

   ChartPoint c(int var1) {
      return (ChartPoint)this.a.get(var1);
   }

   void b() {
      int var1 = this.getCount();
      if (var1 < this.a.size()) {
         com.aspose.cells.b.a.a.ze.a(this.a, var1, this.a.size() - var1);
      }

   }

   void a(ChartPointCollection var1, CopyOptions var2) {
      for(int var3 = 0; var3 < var1.a(); ++var3) {
         ChartPoint var4 = (ChartPoint)var1.a.get(var3);
         ChartPoint var5 = new ChartPoint(this.b, var4.a);
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var5);
         var5.a(var4, var2);
      }

   }
}
